package com.ly.im.repository;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ly.im.pojo.Friend;
import com.ly.im.pojo.User;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author LY
 * @create 2024/2/2 14:54
 * @Description 好友
 */
public interface FriendRepository extends BaseMapper<Friend> {

    @Select("SELECT b.image,b.id,b.username FROM friend  AS `a`\n" +
            "JOIN `user` AS `b` ON a.fid = b.id\n" +
            "WHERE a.uid = #{id}")
    List<User> list(Long id);

    @Select("SELECT b.* FROM apply AS `a`\n" +
            "LEFT JOIN `user` AS `b` ON a.uid = b.id\n" +
            "WHERE a.tid = #{id}")
    List<User> getFriends(Long id);
}
